package msgdef

import "src/zeus/bytestream"

// HeartBeat 心跳消息
type HeartBeat struct {
	Delay uint8
}

func (hb *HeartBeat) Name() string {
	return "HeartBeat"
}

// MarshalTo 序列化
func (hb *HeartBeat) MarshalTo(data []byte) (n int, err error) {
	bw := bytestream.NewByteStream(data)
	return hb.Size(), bw.Marshal(hb)
}

// Unmarshal 反序列化
func (hb *HeartBeat) Unmarshal(data []byte) error {
	br := bytestream.NewByteStream(data)
	return br.Unmarshal(hb)
}

// Size 获取长度
func (hb *HeartBeat) Size() (n int) {
	return 1
}
